package br.xraylol;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

import org.apache.commons.io.monitor.FileAlterationListener;
import org.apache.commons.io.monitor.FileAlterationObserver;

public class FileAlterationExecute implements FileAlterationListener {

	@Override
	public void onDirectoryChange(File arg0) {
		System.out.println("Directory Change");

	}

	@Override
	public void onDirectoryCreate(File arg0) {
		System.out.println("Directory Create");

	}

	@Override
	public void onDirectoryDelete(File arg0) {
		System.out.println("Directory delete");

	}

	@Override
	public void onFileChange(File arg0) {
		System.out.println("Change");

	}

	@Override
	public void onFileCreate(File file) {
		try {
			BufferedImage buffImg = ImageIO.read(file);
			if (!(buffImg.getHeight() < 300)) {
				new Process().startProcess(file);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	@Override
	public void onFileDelete(File arg0) {
		System.out.println("Delete");

	}

	@Override
	public void onStart(FileAlterationObserver arg0) {

	}

	@Override
	public void onStop(FileAlterationObserver arg0) {

	}

}
